package org.quickjsf.core.base.viewmodel;

import java.io.Serializable;
import java.lang.reflect.ParameterizedType;

import org.quickjsf.common.util.DomainUtil;
import org.quickjsf.core.datamodel.DBLazyDataModel;

public class BaseDTPanelViewModel<T> implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1663381449352899700L;
	
	private String idFiled;
	private T selectdEntity;
	private Class<T> entityCls;
	private DBLazyDataModel<T> dataModel;

	
	public BaseDTPanelViewModel() {
		this.entityCls = this.typeClass();
		this.dataModel = new DBLazyDataModel<T>();
		this.idFiled = DomainUtil.getFieldId(this.entityCls);
	}
	
    @SuppressWarnings("unchecked")  
    protected Class<T> typeClass() {  
        return (Class<T>) ((ParameterizedType) getClass()  
                .getGenericSuperclass()).getActualTypeArguments()[0];  
    }

	public DBLazyDataModel<T> getDataModel() {
		return dataModel;
	}

	public T getSelectdEntity() {
		return selectdEntity;
	}

	public void setSelectdEntity(T selectdEntity) {
		this.selectdEntity = selectdEntity;
	}

	public Class<T> getEntityCls() {
		return entityCls;
	}

	public void setEntityCls(Class<T> entityCls) {
		this.entityCls = entityCls;
	}

	public String getIdFiled() {
		return idFiled;
	}

	public void setIdFiled(String idFiled) {
		this.idFiled = idFiled;
	}
}
